package es.techideas.appsjam.model;

import android.content.Context;
import es.techideas.appsjam.GameView;
import es.techideas.appsjam.R;

public class AnimationModelElement extends AbstractModelElement {

	private boolean success;

	public AnimationModelElement(Context context, GameView view, ContainerColor cc, boolean success) {
		super(context, view, cc);
		this.success = success;
	}

	protected int getDrawableId() {
		if(success){
			return getSuccessDrawableId(getContainerColor());
		}
		return R.drawable.puff;
	}

	private int getSuccessDrawableId(ContainerColor containerColor) {
		switch(getContainerColor()){
		case VIDRE:
			return R.drawable.recycled_v;
		case PLASTICS:
			return R.drawable.recycled_p;
		case RESTA:
			return R.drawable.recycled_r;
		case PAPER:
			return R.drawable.recycled_pc;
		case ORGANIC:
			return R.drawable.recycled_o;
		default:
			return R.drawable.recycled_pv;
		}
	}
	
	public void updatePhysics(){
		long now = System.currentTimeMillis();
		double elapsed = getElapsedSeconds(now);
		if(!selected){

			setX(getX() - getVelocityX() * elapsed / SLOW_DOWN_FACTOR);
			setY(getY() - getVelocityY() * elapsed / SLOW_DOWN_FACTOR);

		}
	}
}
